Repository navigation
don't crash the heartbeat thread when the kernel closes while it's starting - #1611
Open
daphnezlin wants to merge 1 commit into
Open
daphnezlin wants to merge 1 commit into
daphnezlin wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If the kernel is closed right after it starts the heartbeat, the heartbeat thread can still be setting up its socket when the context is terminated.
Heartbeat.run()only handles a terminated context inside its main loop, so the thread dies with an uncaught exception from_try_bind_socket:or
ZMQError: Operation not supportedif the context finished terminating before the socket was created.In the test suite this shows up as rare
PytestUnhandledThreadExceptionWarning: Exception in thread Heartbeaterrors on teardown intests/test_curve.py, since those tests callinit_heartbeat()and close the app right after. I found it with a flaky test tool I'm building, which reruns the suite in Docker under CPU limits.test_connection_file_no_curve_keys_by_defaultandtest_curve_keys_are_stable_per_startupeach failed 2 of 60 runs this way.Changes:
Heartbeat.run()returns quietly if the context is terminated while it's creating or binding the socket, the same as it already does when that happens later in the loop.tests/test_heartbeat.py: the context terminated before the thread starts, and while it's binding. Both fail on main and pass with this change.